<template>
	<view class="business">
		<view class="inputlist">
			<view class="left">
				<text class="hx">*</text>
				<text>运营中心名称</text>
			</view>
			<view class="right">
				<input type="text" placeholder="请输入运营中心名称" :disabled="!isD" placeholder-class="inputColor"
					v-model="name">
			</view>
		</view>
		<view class="inputlist">
			<view class="left">
				<text class="hx">*</text>
				<text>联系方式</text>
			</view>
			<view class="right">
				<input type="text" placeholder="请输入联系方式" :disabled="!isD" placeholder-class="inputColor"
					v-model="phone">
			</view>
		</view>

		<view class="btn" v-if="isD">
			<button class="btn_sumbit" @click="ServiceApplyPost">提交申请</button>
		</view>
		<view class="btn" v-if="!isD">
			<button class="btn_sumbit">{{tips}}</button>
		</view>

	</view>
</template>

<script>
	import {
		ServiceApply,
		ServiceApplyPost
	} from "@/api/user.js"
	export default {
		data() {
			return {
				name: '',
				phone: '',
				isD: true,
				tips: ''
			}
		},
		onLoad() {
			this.ServiceApply()
		},
		methods: {
			ServiceApply() {
				ServiceApply().then(res => {
					console.log(res);
					if (res.data.length != 0) {
						this.name = res.data.name
						this.phone = res.data.phone
						if (res.data.status == 0) {
							this.tips = '审核中'
							this.isD = false
						} else if (res.data.status == 1) {
							this.tips = '您已成为服务中心'
							this.isD = false
						}
					} else {
						this.isD = true
					}
				})
			},
			ServiceApplyPost() {
				ServiceApplyPost({
					name: this.name,
					phone: this.phone
				}).then(res => {
					uni.showToast({
						title: res.message,
						icon: "none"
					})
				})
			},

		}
	}
</script>

<style lang="scss">
	page {
		background: #0F172A;
		padding: 10px 0;
	}

	.business {
		background: #1E293B;
		width: 96%;
		margin: 0 auto;
		border-radius: 10px;
		color: #fff;
		padding-bottom: 10px;
	}

	.btn {
		margin-top: 15px;

		.btn_sumbit {
			background: #798AD6;
			color: #fff;
			width: 80%;
			font-size: 14px;
			box-sizing: border-box;
		}
	}

	.imgbox {
		font-size: 14px;
		padding: 10px;
		background-color: #fff;

		image {
			margin-top: 10px;
			width: 100px;
		}
	}

	.inputlist {
		display: flex;
		font-size: 14px;
		padding: 18px 10px;
		border-bottom: 1px solid #303C4F;

		.left {
			width: 30%;
			display: flex;

			.hx {
				display: block;
				width: 5px;
				color: red;
				margin-right: 3px;
			}
		}

		.right {
			width: 70%;

			input {
				font-size: 14px;
			}

			.picker_text {
				color: #fff;
			}

			.inputColor {
				color: #fff;
			}


		}
	}
</style>